package org.flowers.unbeaten.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.flowers.unbeaten.logging.aop.annotation.Logging;
import org.flowers.unbeaten.logging.aop.enums.BusinessType;
import org.flowers.unbeaten.service.IUserService;
import org.flowers.unbeaten.util.DataResult;
import org.flowers.unbeaten.util.HttpSessionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @description 首页控制器
 * @author RyanWang
 * @date 2021-08-09 09:55:14
 * @version 1.0
 */
@Api(tags = "后台系统-首页管理")
@Slf4j
@RestController
@RequestMapping("/dashboard/dashboard")
public class DashboardController {

    @Autowired
    private IUserService userService;

    @Autowired
    private HttpSessionUtils httpSessionUtils;

    @PostMapping("/list")
    @ApiOperation(value = "获取首页数据接口")
    @Logging(title = "首页管理", describe = "获取首页数据", type = BusinessType.QUERY)
    public DataResult list() {
        // 通过accessToken获取userId
        String currentUserId = httpSessionUtils.getCurrentUserId();
        return DataResult.success(userService.getDashboard(currentUserId));
    }

}
